import React, { Component } from 'react'


class Child extends Component{
    render() {
        let {text}=this.props
        return (
          <div>
            {text}
            {/* this.props.text="学习使我快乐" 报错，子组件不能修改父组件state的值 */}
            <button onClick={()=>{
            this.props.text="学习使我快乐"
         }}>子组件-click</button>
          </div>
        )
      }
}
export default class App extends Component {
    state={
        text:"react学习"
    }
  render() {
    return (
      <div>
         <button onClick={()=>{
            this.setState({text:"学什么，放假"})
         }}>父组件click</button>
        <Child text={this.state.text}/>
      </div>
    )
  }
}
